<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <p ref="hello">{{ msg }}</p>
        
        <h2 ref="world">{{ name }}</h2>

        <span>嘿嘿</span>

        <button @click="show">按钮1</button>
        <hr>

        <p ref="wanho">{{ address }}</p>
        <button @click="modify">修改address</button>
    </div>   
</body>

<script>
    var vm = new Vue({
        // el: '#app', // 关联容器/挂载
        data: {
            msg: 'welcome',
            name: 'jack',
            address: '北京'
        },
        methods: {
            show(){
                console.log(111)

                console.log(this.$refs.hello)
            },
            modify(){
                this.address = '上海'
                console.log(this.address)

                // 此时DOM还没更新,需要时间来更新页面, 即响应式也是需要时间的
                this.$nextTick(function(){
                    console.log(this.$refs.wanho.innerText)
                })
            }
        }
    }).$mount('#app')

    // console.log(vm) // Vue实例
    // console.log(vm.$el)
    // console.log(vm.$refs.hello)

    // vm.$mount('#app')
</script>
</html>